package com.zz.ad.service.impl;

import com.zz.ad.dao.CreativeRepository;
import com.zz.ad.entity.Creative;
import com.zz.ad.service.ICreativeService;
import com.zz.ad.client.vo.CreativeRequest;
import com.zz.ad.client.vo.CreativeResponse;
import org.springframework.stereotype.Service;

/**
 * Author: zz
 * Date: 2019/12/30
 * Description:
 */
@Service
public class CreativeServiceImpl implements ICreativeService {

    private CreativeRepository creativeRepository;

    public CreativeServiceImpl(CreativeRepository creativeRepository) {
        this.creativeRepository = creativeRepository;
    }

    @Override
    public CreativeResponse createCreative(CreativeRequest request) {

        Creative creative = creativeRepository.save(request.convertToEntity());

        return new CreativeResponse(creative.getId(), creative.getName());
    }
}
